import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardList {

    private static final String[] SUITS = {"♦","♣","♥","♠"};

    public static List<Card> initList () {
        List<Card> cardList = new ArrayList<>();    //初始化纸牌
        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card = new Card(SUITS[i], j);
                cardList.add(card);
            }
        }
        return cardList;
    }

    public static void shuffle (List<Card> cardList) {
        Random random = new Random();
        for (int i = cardList.size() - 1; i > 0; i--) {
            int pos = random.nextInt(i);
            swap(cardList,i,pos);
        }
    }

    public static void swap (List<Card> cardList, int i, int j) {
        Card tmp = cardList.get(i);
        cardList.set(i,cardList.get(j));
        cardList.set(j,tmp);
    }

    public static void main(String[] args) {
//        List<Card> list = initList();
//        System.out.println(list);
//        shuffle(list);
//        System.out.println(list);
//        List<List<Card>> p = new ArrayList<>();
//        List<Card> p1 = new ArrayList<>();
//        List<Card> p2 = new ArrayList<>();
//        List<Card> p3 = new ArrayList<>();
//        p.add(p1);
//        p.add(p2);
//        p.add(p3);
//        for (int i = 0; i < 5; i++) {
//            {
//                Card card = list.remove(0);
//                p.get(0).add(card);
//            }
//            {
//                Card card = list.remove(0);
//                p.get(1).add(card);
//            }
//            {
//                Card card = list.remove(0);
//                p.get(2).add(card);
//            }
//        }
//        System.out.println("Person 1 :" + p.get(0));
//        System.out.println("Person 2 :" + p.get(1));
//        System.out.println("Person 3 :" + p.get(2));
//        System.out.println("剩余的：" + list);
    }
}
